package com.yksj.healthtalk.adapter;
import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.yksj.healthtalk.ui.R;
/**
 * 
 * @author Tang
 *
 */
public class SalonInterestAdapter extends BaseAdapter {
	private Context context;
	private List<String> list;
	private Boolean isMyself;
	private int length=0;
	private int resources;
	int colors [];
	public SalonInterestAdapter(Context context,List<String> list,Boolean isMyself ,int resources) {
		this.context = context;
		this.list=list;
		this.isMyself=isMyself;
		this.resources=resources;
		 colors  = new  int[list.size()];
	}

	@Override
	public int getCount() {
		if(isMyself){
			return list.size()+1;
		}
		return list.size();
	}

	@Override
	public Object getItem(int arg0) {
		return null;
	}

	@Override
	public long getItemId(int arg0) {
		return arg0;
	}
	
	public void initColors(int length){
		colors  = new  int[length];
	}
	
	public int getTextColorId(int arg0){
		return colors[arg0];
	}
	
	public void setTextColor(int arg0,int colorId){
		colors[arg0] = colorId;
	}
	@Override
	public View getView(int arg0, View arg1, ViewGroup arg2) {
			View 	inflater = LayoutInflater.from(context).inflate(resources,null);
		TextView button = (TextView)inflater.findViewById(R.id.text);
		if(arg0==list.size()){
			button.setText("+");
			return inflater;
		}
		button.setText(list.get(arg0));
		button.setTextColor(context.getResources().getColor(colors[arg0] == 0?R.color.tab_txt_gray:R.color.tab_txt_orange));
		return inflater;
	}

	
}
